package com.ruoyi.inducePest.controller;

import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.inducePest.domain.ChangeRecord;
import com.ruoyi.inducePest.service.ChangeRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: ruoyi_202130504106_李航
 * @description:
 * @author: LiHang
 * @create: 2022-05-16 18:31
 **/
@Slf4j
@RestController
@RequestMapping("/inducePest/changeRecord")
public class ChangeRecordController {

    @Autowired
    private ChangeRecordService changeRecordService;

    /**
     * 根据条件查询修改信息
     * @param changeRecord
     * @return
     */
//    @ApiOperation("根据条件查询列表，支持分页使用 numSize、numPage.根据时间查找，加上beginTime和end参数示例如下：" +
//            "http://localhost:8182/inducePest/changeRecord/selectInfoByCondition")
    @PostMapping("/selectInfoByCondition")
    public TableDataInfo selectInfoByCondition(ChangeRecord changeRecord, Integer pageNum, Integer pageSize) {
        Long userIdL = SecurityUtils.getLoginUser().getUser().getUserId();
        Integer userId=Integer.valueOf(userIdL.intValue());
        changeRecord.setUserId(userId);
        if(changeRecord.getUserId()==1){
            changeRecord.setUserId(null);
        }
        TableDataInfo tableDataInfo = changeRecordService.selectInfoByCondition(changeRecord, pageNum, pageSize);
        return tableDataInfo;
    }
}
